﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.IO;
using System.Data.SqlClient;
using System.Collections;

public partial class ImportExport : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void fileUpload1_Click(object sender, System.EventArgs e)
    {

    }

    protected void importbutton_Click(object sender, System.EventArgs e)
    {
        // Before attempting to use the file, verify
        // that the FileUpload control contains a file.
        if (fileUpload1.HasFile)
        {
            StreamReader file = new StreamReader(Request.Files[0].FileName);
            // Run import
            BusinessTier.Review import = new BusinessTier.Review(HttpContext.Current.User.Identity.Name.ToString());

            UploadStatusLabel.Text = import.importDetails(file);

        }
        else
        {
            // Notify the user that a file was not selected.
            UploadStatusLabel.Text = "You did not specify a file.";

        }
    }

    protected void exportgroupbutton_click(object sender, EventArgs e)
    {
        if (GroupNameDropDown.Text != "-1")
        {
            BusinessTier.Review exportGroup = new BusinessTier.Review(HttpContext.Current.User.Identity.Name.ToString());
            UploadStatusLabel.Text = exportGroup.exportGroupDetails(GroupNameDropDown.Text);
        }
        else
        {
            UploadStatusLabel.Text = "Please specify a group";
        }

        //Create connection to specified database

    }
    protected void exportResultsButton_Click(object sender, EventArgs e)
    {
        if (StudentNameDropDown.Text != "-1")
        {
            BusinessTier.Review exportGroupResults = new BusinessTier.Review(HttpContext.Current.User.Identity.Name.ToString());
            UploadStatusLabel.Text = exportGroupResults.exportResults(StudentNameDropDown.Text);
        }
        else
        {
            UploadStatusLabel.Text = "Please specify a student";
        }
    }
}